package com.kx.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kx.bean.Car;
import com.kx.vo.CarBarVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CarMapper extends BaseMapper<Car> {
    int deleteByPrimaryKey(Integer cid);

    int insertCar(Car record);

    int insertSelective(Car record);

    Car selectByPrimaryKey(Integer cid);

    int updateByPrimaryKeySelective(Car record);

    int updateByPrimaryKey(Car record);

//    @Select("SELECT create_time name, count(create_time) count FROM car GROUP BY create_time HAVING create_time >= DATE_SUB(CURDATE(),INTERVAL 7 DAY);")
    @Select("SELECT create_time name, count(create_time) count FROM car GROUP BY DATE_FORMAT(create_time,\"%Y,%m,%d\") HAVING create_time >= DATE_SUB(CURDATE(),INTERVAL 7 DAY);")
    List<CarBarVO> findAllCarBarVO();
}